﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using DIT.Utility;

namespace DIT.Domain
{
    public class IndividualAccount : Account
    {
        public IndividualAccount(AccountTypeENUM _AccountType, string _PAN, IndividualAccountInfo _PersonalInfo)
            : base(_AccountType, TaxPayerTypeENUM.Individual, _PAN, _PersonalInfo)
        {
        }

        public IndividualAccount(DataRow row)
            : this
                (
                    (AccountTypeENUM)Enum.Parse(typeof(AccountTypeENUM), row["AccountType"] + string.Empty)
                  , row["PAN"] + string.Empty,
                    new IndividualAccountInfo
                    (
                        new AssesseeName(Convert.IsDBNull(row["SurNameOrOrgName"]) ? null : row["SurNameOrOrgName"] + string.Empty
                                   , Convert.IsDBNull(row["FirstName"]) ? null : row["FirstName"] + string.Empty
                                   , Convert.IsDBNull(row["MiddleName"]) ? null : row["MiddleName"] + string.Empty
                                   , Convert.IsDBNull(row["OrgOldName"]) ? null : row["OrgOldName"] + string.Empty)
                      , new Address(Convert.IsDBNull(row["ResidenceNo"]) ? null : row["ResidenceNo"] + string.Empty
                                  , Convert.IsDBNull(row["LocalityOrArea"]) ? null : row["LocalityOrArea"] + string.Empty
                                  , Convert.IsDBNull(row["CityOrTownOrDistrict"]) ? null : row["CityOrTownOrDistrict"] + string.Empty
                                  , Convert.IsDBNull(row["StateCode"]) ? null : (StateCodeENUM?)Enum.Parse(typeof(StateCodeENUM), row["StateCode"] + string.Empty)
                                  , Convert.IsDBNull(row["PinCode"]) ? null : (ulong?)Convert.ToUInt64(row["PinCode"])
                                  , Convert.IsDBNull(row["ResidenceName"]) ? null : row["ResidenceName"] + string.Empty
                                  , Convert.IsDBNull(row["RoadOrStreet"]) ? null : row["RoadOrStreet"] + string.Empty
                                  , Convert.IsDBNull(row["STDcode"]) ? null : (ulong?)Convert.ToUInt64(row["STDcode"])
                                  , Convert.IsDBNull(row["PhoneNo"]) ? null : (ulong?)Convert.ToUInt64(row["PhoneNo"]))
                      , Convert.IsDBNull(row["DOB"]) ? null : (DateTime?)DateTime.Parse(row["DOB"] + string.Empty)
                      , Convert.IsDBNull(row["EmployerCategory"]) ? null : (EmployerCategoryENUM?)Enum.Parse(typeof(EmployerCategoryENUM), row["EmployerCategory"] + string.Empty)
                      , Convert.IsDBNull(row["Gender"]) ? null : (GenderENUM?)Enum.Parse(typeof(GenderENUM), row["Gender"] + string.Empty)
                      , Convert.IsDBNull(row["Status"]) ? null : (StatusENUM?)Enum.Parse(typeof(StatusENUM), row["Status"] + string.Empty)
                      , Convert.IsDBNull(row["MobileNo"]) ? null : (ulong?)Convert.ToUInt64(row["MobileNo"])
                    )
                    {
                        EmailAddress = Convert.IsDBNull(row["EmailAddress"]) ? null : row["EmailAddress"] + string.Empty
                    }
                )
        {
        }

        public static IndividualAccount Sample
        {
            get
            {
                return new IndividualAccount
                    (
                        AccountTypeENUM.TaxPayer
                      , "BCFGD5680W",
                        new IndividualAccountInfo
                            (
                                new AssesseeName("Gupta", "Biswa", "Nath", null)
                              , new Address("30/37", "Barisha", "KOLKATA", StateCodeENUM.WB, 700008, "My Home", "Kailash Ghosh Road", 33, 24943701)
                              , new DateTime(1990, 03, 19)
                              , EmployerCategoryENUM.PSU
                              , GenderENUM.M
                              , StatusENUM.I
                              , 9989908101
                            )
                    );
            }
        }

        public static IndividualAccount Default
        {
            get
            {
                return new IndividualAccount
                    (
                        AccountTypeENUM.TaxPayer
                      , DITConfig.AppSettings["PAN"],
                        new IndividualAccountInfo
                            (
                                new AssesseeName("Gupta", null, null, null)
                              , new Address("30/37", "Barisha", "KOLKATA", StateCodeENUM.WB, 700008, null, null, null, null)
                              , DateTime.Today.AddDays(-1)
                              , EmployerCategoryENUM.PSU
                              , GenderENUM.M
                              , StatusENUM.I
                              , 9989908101
                            )
                    );
            }
        }
    }
}
